Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Use Cucumber Features instead of RSpec Stories

#23

Since Cucumber is going to (eventually) replace RSpec's story running, it would probably be a good idea to generate Cucumber Features instead of RSpec Stories.

Reported by Deleted User · October 25th, 2008 @ 07:11 AM

State: new
Milestone: none
Assigned to: mrflip mrflip

Activity

  1. Bryan
    Bryan

    I've got a fork that generates Cucumber features instead of RSpec stories available Here

    I didn't add or remove any functionality, just moved the stories over and made them work as features.

    January 11th, 2009 @ 09:41 PM

  2. Randy Harmon
    Randy Harmon

    Bryan, did you test by running only rake features? Or also with autospec and/or running cucumber features directly? I'm finding the latter cases failing, though running under rake works great.

    When not in Rake, I get all the code in ra_env.rb complaining about the classes not being loaded (ApplicationController and Fixtures).

    February 15th, 2009 @ 03:07 PM

  3. Bryan
    Bryan

    Randy,

    I typically don't run cucumber with autospec, it seems better suited to RSpec.

    I just ran "cucumber features" and autospec over the features, both with no errors.

    I am using cucumber version 0.1.16, Rails 2.2.2, ZenTest 3.11.1, Ruby 1.8.6 patchlevel 111.

    I don't know if that particular combo is what's doing it for me.

    Bryan

    February 16th, 2009 @ 07:48 PM

  4. John Small
    John Small

    I'm obviously doing something wrong. I downloaded the forked project, created a bare Rails app (2.2.2) ran the usual script/generate authenticated user Sessions --aasm --rspec, then tried rake features and it all went pear shaped.

    After putting in place the things that were missing, a route to '/' and a application view with a

    I'm still getting errors.

    What else needs to be in place from a bare installation to get these features to run without errors?

    Other people are doing this without a problem. Is it my setup? I'm using Rspec & Rspec rails as gems 1.1.12, and Cucumber as a gem 0.1.16.

    March 2nd, 2009 @ 04:30 AM

  5. John Small
    John Small

    OK, I think I've sorted out what's going on. It seems that the latest version of restful-authentication with aasm doesn't allow a user to log in unless they've been activated. So the generators have to take note of the "--aasm" or "--stateful" or "--include-activation" and then add an extra step to activate a new account before it can log in.

    There're a couple of other areas where the features don't match the current behaviour of RA, so places where it says "And Oona should be logged in" has to change to "And Oona should not be logged in", because Oona is an unactivated user and can't log in.

    Also I'll question the extra lines on the "Scenario: Anonymous user can not create an account with bad email". It does extra stuff to create a new user after the verification that a user can't be created with a bad email. The extra stuff goes ahead and puts a correct email in and creates a new user and then fails when testing that login has been succesful because Oona can't log in.

    It looks like it's been copied in from "Scenario: Anonymous user can create an account" because it follows the exact same steps after it gets the error message about the bad email.

    Do you want to edit it or shall I fork it and edit it myself?

    March 2nd, 2009 @ 09:56 AM

  6. Bryan
    Bryan

    John,

    sounds like you have a good contribution to make and are all over it ... I say have at it!

    I've been looking at the rest-auth features in the fbrp project. The feature specs are written in a declarative manner making them easier (I think) to understand. Maybe these would be a better way to go?

    March 2nd, 2009 @ 10:30 AM

  7. John Small
    John Small

    The only awkward bit I can see is the business of responding to --aasm and so on. As the feature generator currently stands it just does a one size fits all set of scenarios. To get it to respond appropriately to user input the template would probably need to be in erb format. Which is not a small change from what is there now. I'll look at it later on this week when I've got some more time.

    March 2nd, 2009 @ 11:12 AM

  8. Sam Pierson
    Sam Pierson

    Randy, Did you ever get your NameError solved? I too am getting "uninitialized constant ApplicationController" Figure out what it was? Thanks, -Sam.

    April 13th, 2009 @ 03:29 PM

  9. Sam Pierson
    Sam Pierson

    Nevermind - I am too new too cucumber. I figured it out.

    April 13th, 2009 @ 08:40 PM

  10. JasonFB
    JasonFB

    Sam, Did you ever get your NameError solved? I am new to cucumber too, I installed restful_authentication and it came with two .feature files and a bunch of step_definitions, looking like this in my features folder:

    features/
    accounts.feature sessions.feature step_definitions/

    ra_env.rb
    ra_navigation_steps.rb
    ra_resource_steps.rb
    ra_response_steps.rb
    rest_auth_features_helper.rb
    user_steps.rb
    

    When I run them, I'm getting

    $ cucumber features uninitialized constant ApplicationController (NameError)
    ./features/step_definitions/ra_env.rb:15 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inpolyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.2.6/lib/polyglot.rb:55:in require' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:95:inrequire_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:104:in each_lib' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:102:ineach' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:102:in each_lib' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:95:inrequire_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:47:in execute!' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:25:inexecute' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/cucumber:9 /usr/bin/cucumber:19:in load' /usr/bin/cucumber:19

    Did I miss something trivial?

    June 24th, 2009 @ 04:30 PM

  11. JasonFB
    JasonFB

    sorry, that text I pasted of the folder structure didn't come out too well :(

    June 24th, 2009 @ 04:31 PM

  12. Sam Pierson
    Sam Pierson

    Yup. It was a while ago but as I recall I just reran "script/generate cucumber" and they world was a happier place.

    June 24th, 2009 @ 05:32 PM

  13. JasonFB
    JasonFB

    I see.

    Yes, thanks. That error has gone away for me.

    Now cucumber is having some problems with what's in these restful_authentication tests. Like I said, I didn't write these, I think they appeared here when I installed restful_authentication? (does that make sense?) That's what I'm guessing. Note: I installed cucumber after I installed restful_authentication, but ran "script/generate cucumber" in the process of getting cucumber setup. So really I'm just running cucumber for the first time on these restful_authentication tests and they are failing out of the box, wonder if anyone else is seeing this.

    $ cucumber features/profile.feature Multiple step definitions have the same Regexp:

    features/step_definitions/user_steps.rb:16:in /^(.*) (.*) user named '(.*)'$/'<br/> features/step_definitions/user_steps.rb:29:in/^there is no (.) user named '(.)'$/'

    user_steps.rb, line 16:

    Given "$an $user_type user named '$login'" do |_, user_type, login|
    create_user! user_type, named_user(login) end

    user_steps.rb, line 29:

    Given "there is no $user_type user named '$login'" do |_, login|
    @user = User.find_by_login(login) @user.destroy! if @user @user.should be_nil end

    June 24th, 2009 @ 09:56 PM

  14. Sam Pierson
    Sam Pierson

    I seem to recall some of the restful_authentication feature specs being broken, or at least not working if you didn't use the default options. If you're interested I ended up fixing them as part of some work I did on it in my github branch: git://github.com/ombwa/restful-authentication.git (I added options for --haml and --email-only).
    -Sam.

    June 25th, 2009 @ 12:36 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.